package cosc617_blackteam;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author Anton
 */
class OrdersOfPartyIterator implements Iterator<Order> {

    private OrderOfIndividualCustomerIterator orderIterator;
   // private I_PersonIterator customerIterator;
    private Iterator<Customer> customerIterator;
    private ArrayList<Order> orderList;
    //  private int index;

    public OrdersOfPartyIterator(ArrayList<Order> orderList, CustomerParty cp) {
        this.orderList = orderList;

        this.customerIterator = cp.iterator();
    }

    @Override
    public boolean hasNext() {
        if (this.customerIterator.hasNext()) // counts the number of people in the party
        {
            this.orderIterator = new OrderOfIndividualCustomerIterator(orderList, (Customer) this.customerIterator.next());
            return this.orderIterator.hasNext();
        }
        return false;
    }

    @Override
    public Order next() {
        if (hasNext()) {

            return this.orderIterator.next();
        }
        return null;
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
